package com.ddch.liaomingtinkerhotfix.base;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * created by 韦敏敏
 * on 2019/12/9
 */
public abstract class BaseActivity extends AppCompatActivity {
    /**
     * Log tag
     */
    protected static String TAG_LOG = null;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TAG_LOG = this.getClass().getSimpleName();
        Bundle extras = getIntent().getExtras();
        if(null != extras){
            getBundleExtras(extras);
        }
        setContentView(getContentViewLayoutID());
        initViewsAndEvnets();
        init();
    }
    protected void getBundleExtras(Bundle bundle){
    }
    // 加载布局
    protected abstract int getContentViewLayoutID();

    /**
     * 加载控件及监听事件
     */
    protected void initViewsAndEvnets(){}
    /*初始化内容*/
    protected void init(){}
    protected <T extends View> T internalFindViewById(int id){
        return ((T)this.findViewById(id));
    }
    /*startActivity*/
    protected  void readyGo(Class<?> clazz){
        Intent intent = new Intent(this, clazz);
        startActivity(intent);
    }
}
